package org.hhy.cloud.crawl.controller;

import org.hhy.cloud.crawl.entity.DictionaryData;
import org.hhy.cloud.crawl.service.DictionaryDataService;
import org.hhy.cloud.crawl.vo.DictionaryDataVO;
import org.lht.boot.lang.util.R;
import org.lht.boot.web.api.param.PagerResult;
import org.lht.boot.web.api.param.QueryParam;
import org.lht.boot.web.api.param.util.ParamServletUtil;
import org.lht.boot.web.common.annotation.AccessLogger;
import org.lht.boot.web.controller.AbstractTreeController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Classname DictionaryDataController
 * @Description 字典管理控制器
 * @Date 2020/11/3 11:11 PM
 * @Created by yupeng
 */

@RestController
@RequestMapping("/data_dict")
@AccessLogger("数据字典")
public class DictionaryDataController extends AbstractTreeController<DictionaryData, String, DictionaryDataVO, DictionaryDataService> {





    /**
     * 获取所有字典类型
     *
     * @param param
     * @param request
     * @return
     */
    @GetMapping("/page/type")
    public R<PagerResult<DictionaryDataVO>> typePage(QueryParam param, HttpServletRequest request) {
        ParamServletUtil.paddingTerms(param, request);
        return R.ok(service.typePage(param).convertTo(this::entityToVo));
    }

}
